import sun.reflect.generics.tree.Tree;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TransferQueue;

public class Solution3 {
    public static void main(String[] args) {
        TreeNode t1= new TreeNode(1);
        TreeNode t2 = new TreeNode(1);
        t1.left = t2;
        Solution3 s = new Solution3();
        boolean validBST = s.isValidBST(t1);

    }
    List<Integer> list = new ArrayList<>();
    boolean result = true;
    public boolean isValidBST(TreeNode root) {
        //对于二叉搜索树采用中序遍历得带的数组是递增的关系
        _recurrent(root);
        return result;
    }
    public void _recurrent(TreeNode root){
        if(root == null || !result){
            return;
        }
        _recurrent(root.left);
        if(list.size()!=0){
            int tempMax = list.get(list.size()-1);
            if(tempMax>=root.val){
                result = false;
            }
        }
        list.add(root.val);
        _recurrent(root.right);
    }
}
